class Conf

	attr_accessor :font, :text_width, :last_file, :bg_array, :fg_array, :toolbox_visible

	def initialize
		# load
		@font = 'Consolas 10'
		@text_width = 400
		@last_file = nil
		@bg_array = [65535, 65535, 65535]
		@fg_array = [0, 0, 0]
		@toolbox_visible = true
	end

	def bg
		return Gdk::Color.new(@bg_array[0], @bg_array[1], @bg_array[2])
	end

	def bg=(color)
		@bg_array = [color.red, color.green, color.red]
	end

	def fg
		return Gdk::Color.new(@fg_array[0], @fg_array[1], @fg_array[2])
	end

	def fg=(color)
		@fg_array = [color.red, color.green, color.red]
	end

	def Conf.load
		begin
			YAML::load(File.open(Conf.filename))
		rescue
			Conf.new
		end
	end

	def save
		f = File.open(Conf.filename, 'w')
		f.print self.to_yaml
		f.close
	end

	def Conf.filename
		return "#{HOME}/.bookwrite.conf"
	end

end
